package org.leetcode.easy.leetcode1114;

public class Solution {
    class Foo {


        Object lock = new Object();

        public Foo() {

        }

        public void first(Runnable printFirst) throws InterruptedException {

            while (Thread.currentThread().getName()!=""){
                lock.wait();
            }
            // printFirst.run() outputs "first". Do not change or remove this line.
            printFirst.run();
            lock.notifyAll();
        }

        public void second(Runnable printSecond) throws InterruptedException {

            // printSecond.run() outputs "second". Do not change or remove this line.
            printSecond.run();
        }

        public void third(Runnable printThird) throws InterruptedException {

            // printThird.run() outputs "third". Do not change or remove this line.
            printThird.run();
        }
    }
}
